This notebook presents the different synthetic experiments exhibited in the associated paper, and provides examples for using the functions and distances developed throughout this project. All of the following has been implemented in R and heavily relies on exterior libraries (igraph and nettools).

0. Loading packages and functions

Start by loading all the different functions.

knitr::opts_knit$set(root.dir = '~/Dropbox/TrackingNetworkChanges')
print(paste("Working directory set to",getwd()))
## [1] "Working directory set to /Users/cdonnat/Dropbox/TrackingNetworkChanges/tests_synthetic_data"
source("../main.R")
## 
## Attaching package: 'gplots'
## The following object is masked from 'package:stats':
## 
##     lowess
## 
## 
## Attaching package: 'igraph'
## The following objects are masked from 'package:stats':
## 
##     decompose, spectrum
## The following object is masked from 'package:base':
## 
##     union
## Warning: package 'Matrix' was built under R version 3.3.2
## Loading required package: MASS
## 
## Attaching package: 'MASS'
## The following object is masked _by_ '.GlobalEnv':
## 
##     ginv
## Loading required package: statnet.common
## Loading required package: network
## network: Classes for Relational Data
## Version 1.13.0 created on 2015-08-31.
## copyright (c) 2005, Carter T. Butts, University of California-Irvine
##                     Mark S. Handcock, University of California -- Los Angeles
##                     David R. Hunter, Penn State University
##                     Martina Morris, University of Washington
##                     Skye Bender-deMoll, University of Washington
##  For citation information, type citation("network").
##  Type help("network-package") to get started.
## 
## Attaching package: 'network'
## The following objects are masked from 'package:igraph':
## 
##     %c%, %s%, add.edges, add.vertices, delete.edges,
##     delete.vertices, get.edge.attribute, get.edges,
##     get.vertex.attribute, is.bipartite, is.directed,
##     list.edge.attributes, list.vertex.attributes,
##     set.edge.attribute, set.vertex.attribute
## sna: Tools for Social Network Analysis
## Version 2.4 created on 2016-07-23.
## copyright (c) 2005, Carter T. Butts, University of California-Irvine
##  For citation information, type citation("sna").
##  Type help(package="sna") to get started.
## 
## Attaching package: 'sna'
## The following objects are masked from 'package:igraph':
## 
##     betweenness, bonpow, closeness, components, degree,
##     dyad.census, evcent, hierarchy, is.connected, neighborhood,
##     triad.census
print("All functions loaded.")
## [1] "All functions loaded."

I. Random Graph generation

Here we try generating different instances of random graphs. Indeed, if the Erdos-Renyi random graph often appears to be one of the simplest and most natural random graph to generate, numerous works throughout the literature have underlined its limitations when it comes to reproducing “real life graphs”. This is why we propose to enrich our synthetic graph library (for our experiments) by synthetizing other types of random structures that have been argued to be more realsitic: the Power Law graph (Barabasi-Albert model), an Island graph, a dot product graph and an SBM graph. All of the R igraph generation functions for these graphs have been wrapped in the same function (generate_realistic_adjacency), and the following code snipppets show how to generate a variety of such different graphs.

N=50
Adj=generate_realistic_adjacency(N,opts=0,args=list(),verbose=TRUE,p=0.16)
## [1] "Type of graph generated:  ER"

generate_realistic_adjacency(N,opts=1,args=list(),verbose=TRUE,pow= 2.4)
## [1] "Type of graph generated:  Power Law"
## [1] "power graph: p= 2.4"

## IGRAPH U--- 50 49 -- Barabasi graph
## + attr: name (g/c), power (g/n), m (g/n), zero.appeal (g/n),
## | algorithm (g/c)
## + edges:
##  [1]  1-- 2  2-- 3  2-- 4  2-- 5  2-- 6  3-- 7  1-- 8  4-- 9  2--10  2--11
## [11]  2--12  2--13  2--14  2--15  2--16  2--17  2--18  2--19  2--20  2--21
## [21]  2--22  2--23  2--24  2--25  2--26  2--27  2--28 10--29  2--30  2--31
## [31]  2--32  2--33  2--34  2--35  2--36  2--37  2--38 31--39  2--40  2--41
## [41]  2--42  2--43  2--44  2--45  2--46  2--47  2--48  2--49  2--50
G=generate_realistic_adjacency(N,opts=2,args=list(),verbose=TRUE,islands.n=4,islands.size=18,islands.pin=0.2,n.inter=7)
## [1] "Type of graph generated:  Island"
## [1] "island graph: islands.n= 4 18"

G=generate_realistic_adjacency(N,opts=3,args=list(),verbose=TRUE,K=10)
## [1] "Type of graph generated:  Dot Product"
## [1] "dot product graph"

G=generate_realistic_adjacency(N,opts=4,args=list(),verbose=TRUE,pm=cbind( c(0.4,0.1, 0.001), c(.1,0.2, .01),c(.001,0.01, .5)))
## [1] "Type of graph generated:  SBM"
## [1] 50
## [1] "stochastic block model: block size 10"
## [2] "stochastic block model: block size 10"
## [3] "stochastic block model: block size 10"

II. Generate smooth evolution process

N=70
p0=0.15
p=0.5
p_disp=0.3
p_creation=0.01
prop=0.3
dist_smooth=test_smooth_RD_changes(N,p0,p,p_disp,p_creation,prop,T=11,alphas=c(0.1,0.4,0.9,1.2,3),verbose=TRUE, go_plot=TRUE,initial_message=TRUE,save_graph_seq=T, name_file_ext="",path_to_graph='/Users/cdonnat/Dropbox/TrackingNetworkChanges/tests_synthetic_data/generated_graphs/',name_graph='ER_70nodes',path2plot='/Users/cdonnat/Dropbox/TrackingNetworkChanges/tests_synthetic_data/plots_experiments/')
## [1] "Investigating the distance for evolution of a graph over time with random changes:"
## [1] "At each time iteration,  30 % of nodes are randomly reassigned (ER-model)"
## [1] "time:  1"
## [1] "time:  2"
## [1] "time:  3"
## [1] "time:  4"
## [1] "time:  5"
## [1] "time:  6"
## [1] "time:  7"
## [1] "time:  8"
## [1] "time:  9"
## [1] "time:  10"

Try the previous for different types of topology.

For instance, for a Preferential Attachment model, this evolution process spans the following distances.

N=70

m=10
p_modified=0.6
dist_smooth_PA=test_smooth_Realistic_changes(N,m,m_disp=0,m_creation=0, p_modified, p_disp=0.3,p_creation=0.01,T=11,opts=1,alphas=c(0.1,0.4,0.9,1.2,3),verbose=FALSE,go_plot=TRUE,initial_message=TRUE,save_graph_seq=TRUE,path_to_graph='./tests_synthetic_data/generated_graphs/', name_file_ext="",very_verbose=F,path2plots='./tests_synthetic_data/plots_experiments/')
## [1] "Type of graph generated:  Power Law"
## [1] "power graph: p= 0.9"

## [1] "Investigating the distance for evolution of a graph over time with random changes:"
## [1] "A graph with N= 70 nodes is considered as per creation model  1"
## [1] "At each time iteration,  10 edges are either randomly reassigned or disppear with proba  0.3"
## [1] "Probablity of creation a a new edge for each vertex=  0.01"

III. Generate evolution process with change point

We now focus on the distances ability to capture changes in dynamics.

test_ER_changepoint=test_change_point(N=30,p0=0.4,p=0.4,prop=0.05,prop2=0.2,p2=0.4, T=21,verbose=FALSE,go_plot=TRUE,initial_message=TRUE,save_graph_seq=TRUE)
## [1] "Investigating the ability of the distance to detect dynamic regime changes"
## [1] "An ER graph with N= 30 nodes is considered, with edge proba= 0.4"
## [1] "At time t=10, the proportion of nodes randomly reassigned changes from 0.05  to  0.2 with new connection proba=  0.4"

 print(test_ER_changepoint$dist) 
##                             X1          X2          X3           X4
## Hamming1          1.379310e-02 0.013793103 0.013793103 0.0229885057
## Jaccard           3.278689e-02 0.032786885 0.032786885 0.0540540541
## Spanning Trees    1.003672e-04 0.000589502 0.002275186 0.0013518578
## Hamming           1.379310e-02 0.013793103 0.013793103 0.0229885057
## IM                4.692207e-03 0.005087630 0.010812503 0.0089409637
## HIM               1.030210e-02 0.010395520 0.012392738 0.0174415055
## alpha=0.5,order=5 1.512126e+00 1.057295020 2.213696909 1.9037481957
## alpha=0.5,order=3 3.495663e-02 0.031410396 0.035561575 0.0549919709
## alpha=0.9,order=3 2.069204e-02 0.019735396 0.020666529 0.0338518912
## ST norm           5.018358e-05 0.000294751 0.001137592 0.0006759288
## f(l)=exp(-0.1l)   7.255643e-02 0.057865891 0.058522878 0.0496052727
## f(l)=exp(-0.4l)   2.902257e-01 0.231463564 0.234091511 0.1984210907
## f(l)=exp(-0.9l)   6.530079e-01 0.520793018 0.526705900 0.4464474540
## f(l)=exp(-1.2l)   8.706771e-01 0.694390691 0.702274533 0.5952632720
## f(l)=exp(-3l)     2.176693e+00 1.735976728 1.755686332 1.4881581801
## f(l)= l. 1(l<2)   4.864282e-01 1.961225430 1.954712809 0.2526499605
##                            X5           X6           X7           X8
## Hamming1          0.027586207 0.0183908046 0.0183908046 9.195402e-03
## Jaccard           0.064516129 0.0434782609 0.0434782609 2.197802e-02
## Spanning Trees    0.002967068 0.0002402733 0.0003134237 1.613220e-04
## Hamming           0.027586207 0.0183908046 0.0183908046 9.195402e-03
## IM                0.016980114 0.0037371615 0.0046307323 5.018703e-03
## HIM               0.022905492 0.0132700428 0.0134101711 7.407523e-03
## alpha=0.5,order=5 3.351388824 1.5148312520 3.1272808241 7.873393e-01
## alpha=0.5,order=3 0.070931499 0.0441406362 0.0519033508 2.180968e-02
## alpha=0.9,order=3 0.041713359 0.0269660135 0.0290053475 1.340539e-02
## ST norm           0.001483533 0.0001201366 0.0001567119 8.066098e-05
## f(l)=exp(-0.1l)   0.050864796 0.0687098101 0.0597378279 5.041267e-02
## f(l)=exp(-0.4l)   0.203459186 0.2748392404 0.2389513115 2.016507e-01
## f(l)=exp(-0.9l)   0.457783168 0.6183882910 0.5376404508 4.537140e-01
## f(l)=exp(-1.2l)   0.610377557 0.8245177213 0.7168539344 6.049520e-01
## f(l)=exp(-3l)     1.525943894 2.0612943032 1.7921348361 1.512380e+00
## f(l)= l. 1(l<2)   1.995749554 1.9262229760 0.3992747012 2.032807e+00
##                             X9          X10         X11         X12
## Hamming1          0.0275862069 0.0505747126 0.073563218 0.045977011
## Jaccard           0.0645161290 0.1151832461 0.163265306 0.105263158
## Spanning Trees    0.0012049387 0.0006901281 0.001239622 0.002000929
## Hamming           0.0275862069 0.0505747126 0.073563218 0.045977011
## IM                0.0077330637 0.0069370548 0.007457381 0.013768397
## HIM               0.0202583203 0.0360965669 0.052283648 0.033937106
## alpha=0.5,order=5 3.9567396098 4.8673587861 8.300021845 8.850230416
## alpha=0.5,order=3 0.0752905877 0.1209613378 0.194028347 0.130101979
## alpha=0.9,order=3 0.0428818696 0.0738414638 0.113284366 0.072143889
## ST norm           0.0006024693 0.0003450640 0.000619811 0.001000464
## f(l)=exp(-0.1l)   0.0643226721 0.0973314861 0.080482336 0.078494893
## f(l)=exp(-0.4l)   0.2572906884 0.3893259443 0.321929345 0.313979572
## f(l)=exp(-0.9l)   0.5789040490 0.8759833747 0.724341027 0.706454037
## f(l)=exp(-1.2l)   0.7718720653 1.1679778330 0.965788036 0.941938716
## f(l)=exp(-3l)     1.9296801632 2.9199445824 2.414470091 2.354846790
## f(l)= l. 1(l<2)   2.0231630949 2.0264956440 2.707603948 1.949385809
##                            X13         X14          X15          X16
## Hamming1          0.0689655172 0.064367816 0.0597701149 6.896552e-02
## Jaccard           0.1538461538 0.144329897 0.1347150259 1.538462e-01
## Spanning Trees    0.0006703153 0.000431864 0.0016163570 1.079392e-03
## Hamming           0.0689655172 0.064367816 0.0597701149 6.896552e-02
## IM                0.0064584643 0.007632811 0.0076023266 1.691325e-02
## HIM               0.0489793545 0.045833806 0.0426043543 5.021106e-02
## alpha=0.5,order=5 5.8776452124 7.637431433 9.0862933643 1.057958e+01
## alpha=0.5,order=3 0.1655291353 0.169690286 0.1615539722 1.820309e-01
## alpha=0.9,order=3 0.1014132824 0.098855568 0.0922504377 1.049264e-01
## ST norm           0.0003351576 0.000215932 0.0008081783 5.396961e-04
## f(l)=exp(-0.1l)   0.0897291234 0.058530476 0.0567938311 9.436884e-02
## f(l)=exp(-0.4l)   0.3589164936 0.234121903 0.2271753243 3.774754e-01
## f(l)=exp(-0.9l)   0.8075621106 0.526774283 0.5111444797 8.493195e-01
## f(l)=exp(-1.2l)   1.0767494808 0.702365710 0.6815259730 1.132426e+00
## f(l)=exp(-3l)     2.6918737021 1.755914276 1.7038149325 2.831065e+00
## f(l)= l. 1(l<2)   1.9024220261 0.345095420 0.3566464383 2.134348e+00
##                            X17          X18          X19         X20
## Hamming1          7.356322e-02 0.0643678161 0.0689655172 0.055172414
## Jaccard           1.632653e-01 0.1443298969 0.1538461538 0.125000000
## Spanning Trees    1.864511e-03 0.0001564952 0.0010290654 0.003109277
## Hamming           7.356322e-02 0.0643678161 0.0689655172 0.055172414
## IM                2.461187e-02 0.0097864829 0.0118643634 0.017219593
## HIM               5.485112e-02 0.0460379789 0.0494823488 0.040868751
## alpha=0.5,order=5 1.001215e+01 9.0146329185 9.8632509158 8.793173937
## alpha=0.5,order=3 1.887662e-01 0.1699377659 0.1850335162 0.149472222
## alpha=0.9,order=3 1.110251e-01 0.0983903864 0.1061163803 0.085274124
## ST norm           9.322551e-04 0.0000782476 0.0005145326 0.001554637
## f(l)=exp(-0.1l)   1.043943e-01 0.0978465522 0.0727074930 0.098261921
## f(l)=exp(-0.4l)   4.175774e-01 0.3913862086 0.2908299720 0.393047684
## f(l)=exp(-0.9l)   9.395491e-01 0.8806189694 0.6543674370 0.884357288
## f(l)=exp(-1.2l)   1.252732e+00 1.1741586259 0.8724899160 1.179143051
## f(l)=exp(-3l)     3.131830e+00 2.9353965648 2.1812247899 2.947857628
## f(l)= l. 1(l<2)   2.115952e+00 0.6096138256 2.0258021968 2.069915596

We also try varying the type of graph to assess the distances’ sensitivity to the density and topology of the graph. For instance, for a Preferential Attachment graph with power 0.9 (default setting), the distances are the following:

change_pointPA=test_change_point_realistic(N=70,m=c(10,20),p_mod=c(0.6,0.2),p_disp=c(0.1,0.2),p_creation=c(0.0,0.0),opts=1, T=21,verbose=TRUE,m_disp=c(0,0,0),m_creation=c(2,5,0),go_plot=TRUE,initial_message=TRUE,very_verbose=FALSE,save_graph_seq=FALSE,name_file_ext="")
## [1] "Investigating the ability of the distance to detect dynamic regime changes"
## [1] "A graph with N= 70 nodes is considered as per creation model  1"
## [1] "At time t=10, the number of randomly reassigned edges changes from 10  to  20 with new change proba=  NA  vs  0.5 and deletion 0.2"
## [1] "Type of graph generated:  Power Law"
## [1] "power graph: p= 0.9"

## [1] "time:  1"
## [1] "time:  2"
## [1] "time:  3"
## [1] "time:  4"
## [1] "time:  5"
## [1] "time:  6"
## [1] "time:  7"
## [1] "time:  8"
## [1] "time:  9"
## [1] "time:  10"
## [1] "time:  11"
## [1] "time:  12"
## [1] "time:  13"
## [1] "time:  14"
## [1] "changed back"
## [1] "time:  15"
## [1] "changed back"
## [1] "time:  16"
## [1] "changed back"
## [1] "time:  17"
## [1] "changed back"
## [1] "time:  18"
## [1] "changed back"
## [1] "time:  19"
## [1] "changed back"
## [1] "time:  20"
## [1] "changed back"

print(change_pointPA$dist) 
##                            X1          X2         X3          X4
## Hamming1          0.005797101 0.009109731 0.01076605 0.009937888
## Jaccard           0.184210526 0.275000000 0.31707317 0.296296296
## Spanning Trees    2.232132305 0.039977334 0.20151008 0.304272042
## Hamming           0.005797101 0.009109731 0.01076605 0.009937888
## IM                0.015484760 0.012875329 0.01664330 0.024494787
## HIM               0.011691539 0.011152607 0.01401619 0.018691659
## alpha=0.5,order=5 0.009339584 0.015693207 0.01929394 0.018458506
## alpha=0.5,order=3 0.006975986 0.011266207 0.01352880 0.012671164
## alpha=0.9,order=3 0.006199174 0.009846298 0.01170640 0.010865914
## ST norm           1.000000000 0.019986005 0.10041548 0.150973039
## f(l)=exp(-0.1l)   0.131447521 0.128885008 0.06529757 0.085605883
## f(l)=exp(-0.4l)   0.525790083 0.515540034 0.26119029 0.342423531
## f(l)=exp(-0.9l)   1.183027688 1.159965076 0.58767814 0.770452946
## f(l)=exp(-1.2l)   1.577370250 1.546620101 0.78357086 1.027270594
## f(l)=exp(-3l)     3.943425625 3.866550252 1.95892715 2.568176486
## f(l)= l. 1(l<2)   3.038533779 2.253868867 1.95363438 0.739199320
##                            X5          X6          X7          X8
## Hamming1          0.007453416 0.008281573 0.009109731 0.007453416
## Jaccard           0.230769231 0.253164557 0.275000000 0.230769231
## Spanning Trees    0.316919911 0.410728555 0.111989129 0.469356818
## Hamming           0.007453416 0.008281573 0.009109731 0.007453416
## IM                0.013831241 0.011169748 0.011465893 0.012945968
## HIM               0.011109830 0.009832287 0.010355045 0.010562942
## alpha=0.5,order=5 0.014076161 0.015653372 0.017149594 0.012896332
## alpha=0.5,order=3 0.009577173 0.010643671 0.011666001 0.009215203
## alpha=0.9,order=3 0.008176966 0.009084881 0.009970812 0.008047475
## ST norm           0.157146856 0.202525120 0.055936116 0.230463025
## f(l)=exp(-0.1l)   0.083658492 0.080365531 0.095212170 0.058276238
## f(l)=exp(-0.4l)   0.334633968 0.321462124 0.380848678 0.233104952
## f(l)=exp(-0.9l)   0.752926427 0.723289780 0.856909526 0.524486141
## f(l)=exp(-1.2l)   1.003901903 0.964386373 1.142546034 0.699314855
## f(l)=exp(-3l)     2.509754757 2.410965934 2.856365085 1.748287138
## f(l)= l. 1(l<2)   0.683080732 0.664452250 0.901433311 2.807419378
##                            X9         X10         X11         X12
## Hamming1          0.004140787 0.004968944 0.007453416 0.009109731
## Jaccard           0.135135135 0.160000000 0.230769231 0.275000000
## Spanning Trees    0.371304183 0.553156162 0.181878669 0.019213946
## Hamming           0.004140787 0.004968944 0.007453416 0.009109731
## IM                0.007260008 0.009813993 0.006995394 0.007724073
## HIM               0.005909900 0.007778331 0.007228034 0.008445368
## alpha=0.5,order=5 0.007111222 0.009382055 0.013307028 0.015878267
## alpha=0.5,order=3 0.005113688 0.006376065 0.009339185 0.011325946
## alpha=0.9,order=3 0.004472805 0.005445121 0.008091646 0.009868376
## ST norm           0.183548155 0.269735068 0.090689473 0.009606678
## f(l)=exp(-0.1l)   0.040449541 0.050501737 0.075591983 0.069627294
## f(l)=exp(-0.4l)   0.161798163 0.202006946 0.302367933 0.278509177
## f(l)=exp(-0.9l)   0.364045866 0.454515629 0.680327849 0.626645648
## f(l)=exp(-1.2l)   0.485394488 0.606020838 0.907103799 0.835527531
## f(l)=exp(-3l)     1.213486219 1.515052096 2.267759498 2.088818827
## f(l)= l. 1(l<2)   2.785366259 2.794292343 2.060418725 1.993625216
##                           X13         X14         X15         X16
## Hamming1          0.006625259 0.004968944 0.007453416 0.011594203
## Jaccard           0.207792208 0.160000000 0.230769231 0.337349398
## Spanning Trees    1.699692811 1.913685491 0.087475753 0.144428336
## Hamming           0.006625259 0.004968944 0.007453416 0.011594203
## IM                0.011765998 0.011601325 0.007628044 0.008374651
## HIM               0.009548109 0.008924157 0.007541236 0.010113366
## alpha=0.5,order=5 0.013007454 0.009391611 0.012857586 0.022024251
## alpha=0.5,order=3 0.008637459 0.006362515 0.009212200 0.014899967
## alpha=0.9,order=3 0.007305100 0.005436666 0.008050323 0.012707342
## ST norm           0.690989220 0.742865255 0.043710008 0.072088900
## f(l)=exp(-0.1l)   0.053531351 0.078876235 0.085152261 0.062475095
## f(l)=exp(-0.4l)   0.214125403 0.315504939 0.340609043 0.249900379
## f(l)=exp(-0.9l)   0.481782156 0.709886112 0.766370347 0.562275852
## f(l)=exp(-1.2l)   0.642376208 0.946514817 1.021827129 0.749701136
## f(l)=exp(-3l)     1.605940520 2.366287041 2.554567822 1.874252841
## f(l)= l. 1(l<2)   0.450714606 2.855217577 2.814025744 0.596190256
##                           X17         X18         X19        X20
## Hamming1          0.010766046 0.009937888 0.011594203 0.01325052
## Jaccard           0.317073171 0.296296296 0.337349398 0.37647059
## Spanning Trees    0.857728401 0.881290183 0.344034820 0.03001199
## Hamming           0.010766046 0.009937888 0.011594203 0.01325052
## IM                0.008791652 0.014114848 0.005595169 0.02101975
## HIM               0.009828552 0.012206362 0.009103061 0.01756995
## alpha=0.5,order=5 0.020376088 0.018335258 0.022128050 0.02529138
## alpha=0.5,order=3 0.013793493 0.012638417 0.014964543 0.01710704
## alpha=0.9,order=3 0.011778800 0.010854646 0.012740395 0.01456162
## ST norm           0.404371667 0.414179015 0.170340590 0.01500487
## f(l)=exp(-0.1l)   0.060476171 0.062381694 0.090370073 0.12080901
## f(l)=exp(-0.4l)   0.241904685 0.249526778 0.361480291 0.48323604
## f(l)=exp(-0.9l)   0.544285542 0.561435250 0.813330655 1.08728109
## f(l)=exp(-1.2l)   0.725714056 0.748580333 1.084440873 1.44970812
## f(l)=exp(-3l)     1.814285139 1.871450833 2.711102183 3.62427030
## f(l)= l. 1(l<2)   0.586364166 0.586238298 3.510017428 3.35491209

If we try a different type of Power law graph (varing the power):

change_pointPA=test_change_point_realistic(N=70,m=c(10,20),p_mod=c(0.6,0.2),p_disp=c(0.1,0.2),p_creation=c(0.0,0.0),opts=1, T=21,verbose=TRUE,m_disp=c(0,0,0),m_creation=c(2,5,0),go_plot=TRUE,initial_message=TRUE,very_verbose=FALSE,save_graph_seq=FALSE,name_file_ext="",power=2.4)
## [1] "Investigating the ability of the distance to detect dynamic regime changes"
## [1] "A graph with N= 70 nodes is considered as per creation model  1"
## [1] "At time t=10, the number of randomly reassigned edges changes from 10  to  20 with new change proba=  NA  vs  0.5 and deletion 0.2"
## [1] "Type of graph generated:  Power Law"
## [1] "power graph: p= 0.9"

## [1] "time:  1"
## [1] "time:  2"
## [1] "time:  3"
## [1] "time:  4"
## [1] "time:  5"
## [1] "time:  6"
## [1] "time:  7"
## [1] "time:  8"
## [1] "time:  9"
## [1] "time:  10"
## [1] "time:  11"
## [1] "time:  12"
## [1] "time:  13"
## [1] "time:  14"
## [1] "changed back"
## [1] "time:  15"
## [1] "changed back"
## [1] "time:  16"
## [1] "changed back"
## [1] "time:  17"
## [1] "changed back"
## [1] "time:  18"
## [1] "changed back"
## [1] "time:  19"
## [1] "changed back"
## [1] "time:  20"
## [1] "changed back"

print(change_pointPA$dist) 
##                            X1          X2          X3          X4
## Hamming1          0.004968944 0.009937888 0.010766046 0.009109731
## Jaccard           0.160000000 0.296296296 0.317073171 0.275000000
## Spanning Trees    2.026943854 0.050937030 0.094510066 0.159131410
## Hamming           0.004968944 0.009937888 0.010766046 0.009109731
## IM                0.021188597 0.005277054 0.005769983 0.017502608
## HIM               0.015389071 0.007956410 0.008637142 0.013952213
## alpha=0.5,order=5 0.008632571 0.017269181 0.018773325 0.015789585
## alpha=0.5,order=3 0.006161481 0.012334311 0.013378314 0.011277364
## alpha=0.9,order=3 0.005374627 0.010756271 0.011657140 0.009844746
## ST norm           1.000000000 0.025463010 0.047219890 0.079398227
## f(l)=exp(-0.1l)   0.128784093 0.095667651 0.075596066 0.077847206
## f(l)=exp(-0.4l)   0.515136372 0.382670604 0.302384264 0.311388823
## f(l)=exp(-0.9l)   1.159056837 0.861008859 0.680364593 0.700624852
## f(l)=exp(-1.2l)   1.545409115 1.148011812 0.907152791 0.934166470
## f(l)=exp(-3l)     3.863522789 2.870029531 2.267881978 2.335416174
## f(l)= l. 1(l<2)   1.264117567 2.053899107 3.392562944 2.834121822
##                            X5          X6          X7          X8
## Hamming1          0.008281573 0.006625259 0.006625259 0.007453416
## Jaccard           0.253164557 0.207792208 0.207792208 0.230769231
## Spanning Trees    0.152208941 0.690831829 0.272160048 0.456650177
## Hamming           0.008281573 0.006625259 0.006625259 0.007453416
## IM                0.015827390 0.007897029 0.009738791 0.011180227
## HIM               0.012631127 0.007288934 0.008328809 0.009501339
## alpha=0.5,order=5 0.015790372 0.013226597 0.012968301 0.014278866
## alpha=0.5,order=3 0.010677689 0.008715371 0.008647405 0.009640509
## alpha=0.9,order=3 0.009094412 0.007334040 0.007314106 0.008199894
## ST norm           0.075957880 0.332303891 0.135246233 0.224438410
## f(l)=exp(-0.1l)   0.059591313 0.074490244 0.087591656 0.050413591
## f(l)=exp(-0.4l)   0.238365250 0.297960977 0.350366626 0.201654364
## f(l)=exp(-0.9l)   0.536321813 0.670412199 0.788324908 0.453722319
## f(l)=exp(-1.2l)   0.715095751 0.893882932 1.051099877 0.604963093
## f(l)=exp(-3l)     1.787739377 2.234707329 2.627749693 1.512407731
## f(l)= l. 1(l<2)   0.540966689 0.705304885 0.791248656 0.396099149
##                            X9         X10         X11         X12
## Hamming1          0.005797101 0.004968944 0.004968944 0.002484472
## Jaccard           0.184210526 0.160000000 0.160000000 0.083333333
## Spanning Trees    1.060660071 0.793003274 1.841742253 1.157716803
## Hamming           0.005797101 0.004968944 0.004968944 0.002484472
## IM                0.017498356 0.009380286 0.010699522 0.005723397
## HIM               0.013034548 0.007506003 0.008341768 0.004411909
## alpha=0.5,order=5 0.011123315 0.008713904 0.009003633 0.004988179
## alpha=0.5,order=3 0.007495835 0.006186323 0.006265794 0.003268728
## alpha=0.9,order=3 0.006375151 0.005383612 0.005409369 0.002749433
## ST norm           0.485633331 0.376951656 0.726309261 0.521835197
## f(l)=exp(-0.1l)   0.060416775 0.099668889 0.089337652 0.082423108
## f(l)=exp(-0.4l)   0.241667098 0.398675557 0.357350609 0.329692430
## f(l)=exp(-0.9l)   0.543750971 0.897020004 0.804038870 0.741807968
## f(l)=exp(-1.2l)   0.725001295 1.196026672 1.072051826 0.989077290
## f(l)=exp(-3l)     1.812503238 2.990066679 2.680129565 2.472693225
## f(l)= l. 1(l<2)   0.462618820 0.947614248 0.813948403 0.702120021
##                           X13         X14        X15         X16
## Hamming1          0.004968944 0.009937888 0.01325052 0.009937888
## Jaccard           0.160000000 0.296296296 0.37647059 0.296296296
## Spanning Trees    0.451721109 0.209228193 0.35746740 0.406607164
## Hamming           0.004968944 0.009937888 0.01325052 0.009937888
## IM                0.015717070 0.009611156 0.01238074 0.017028519
## HIM               0.011655829 0.009775887 0.01282301 0.013941522
## alpha=0.5,order=5 0.009283376 0.018453718 0.02426800 0.018598308
## alpha=0.5,order=3 0.006356304 0.012680994 0.01680650 0.012718856
## alpha=0.9,order=3 0.005441956 0.010873204 0.01446184 0.010885082
## ST norm           0.222096730 0.104234124 0.17685445 0.200548124
## f(l)=exp(-0.1l)   0.084196579 0.068035495 0.11934541 0.081935623
## f(l)=exp(-0.4l)   0.336786318 0.272141981 0.47738164 0.327742494
## f(l)=exp(-0.9l)   0.757769215 0.612319458 1.07410870 0.737420611
## f(l)=exp(-1.2l)   1.010358953 0.816425944 1.43214493 0.983227481
## f(l)=exp(-3l)     2.525897383 2.041064860 3.58036232 2.458068702
## f(l)= l. 1(l<2)   0.803262985 0.566441359 2.82829608 2.723836947
##                           X17         X18         X19         X20
## Hamming1          0.005797101 0.008281573 0.007453416 0.007453416
## Jaccard           0.184210526 0.253164557 0.230769231 0.230769231
## Spanning Trees    0.090979845 0.752812884 0.813163706 0.605859876
## Hamming           0.005797101 0.008281573 0.007453416 0.007453416
## IM                0.003670974 0.008558912 0.010671198 0.011481951
## HIM               0.004851929 0.008421385 0.009204018 0.009679582
## alpha=0.5,order=5 0.010064098 0.014954056 0.014850881 0.015824272
## alpha=0.5,order=3 0.007196371 0.010432101 0.009797148 0.010078431
## alpha=0.9,order=3 0.006276418 0.009011772 0.008248444 0.008343447
## ST norm           0.045458570 0.359582606 0.385566521 0.293991613
## f(l)=exp(-0.1l)   0.043049554 0.058377551 0.085760085 0.068629416
## f(l)=exp(-0.4l)   0.172198218 0.233510204 0.343040338 0.274517666
## f(l)=exp(-0.9l)   0.387445990 0.525397958 0.771840761 0.617664748
## f(l)=exp(-1.2l)   0.516594653 0.700530611 1.029121014 0.823552998
## f(l)=exp(-3l)     1.291486633 1.751326527 2.572802536 2.058882495
## f(l)= l. 1(l<2)   0.389700060 0.436230452 0.821640883 0.593265394

We now test the Island graph topology (this graph only has the 30 default nodes)

change_pointIsland=test_change_point_realistic(N=70,m=c(10,20),p_mod=c(0.6,0.2),p_disp=c(0.1,0.2),p_creation=c(0.0,0.0),opts=2, T=21,verbose=TRUE,m_disp=c(0,0,0),m_creation=c(2,5,0),go_plot=TRUE,initial_message=TRUE,very_verbose=FALSE,save_graph_seq=FALSE,name_file_ext="")
## [1] "Investigating the ability of the distance to detect dynamic regime changes"
## [1] "A graph with N= 70 nodes is considered as per creation model  2"
## [1] "At time t=10, the number of randomly reassigned edges changes from 10  to  20 with new change proba=  NA  vs  0.5 and deletion 0.2"
## [1] "Type of graph generated:  Island"
## [1] "island graph: islands.n= 3 9"
## [1] "time:  1"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  2"
## [1] "time:  3"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  4"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  5"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  6"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  7"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  8"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  9"
## [1] "time:  10"
## [1] "time:  11"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  12"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  13"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  14"
## [1] "changed back"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  15"
## [1] "changed back"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  16"
## [1] "changed back"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  17"
## [1] "changed back"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  18"
## [1] "changed back"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  19"
## [1] "changed back"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!
## [1] "time:  20"
## [1] "changed back"
## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

## Warning: Edge weight should be >= 0 and <= 1, scaling has been
## automatically applied!

print(change_pointIsland$dist)
##                            X1          X2          X3         X4
## Hamming1          0.005383023 0.009523810 0.008695652 0.00952381
## Jaccard           0.232142857 0.370967742 0.350000000 0.37704918
## Spanning Trees    0.007351114 0.014411332 0.032434244 0.04451061
## Hamming           0.086894587 0.065527066 0.102564103 0.03276353
## IM                0.232061339 0.014132677 0.237206664 0.01296098
## HIM               0.175218627 0.047400047 0.182738059 0.02491421
## alpha=0.5,order=5 0.130532650 0.221502205 0.226350809 0.20506454
## alpha=0.5,order=3 0.072001391 0.124375028 0.125918849 0.11852918
## alpha=0.9,order=3 0.048632543 0.085649593 0.086200088 0.08398020
## ST norm           0.003675540 0.007205541 0.016215701 0.02225163
## f(l)=exp(-0.1l)   0.060619583 0.072916338 0.064817557 0.05576352
## f(l)=exp(-0.4l)   0.242478330 0.291665351 0.259270227 0.22305406
## f(l)=exp(-0.9l)   0.545576243 0.656247040 0.583358010 0.50187164
## f(l)=exp(-1.2l)   0.727434991 0.874996053 0.777810680 0.66916219
## f(l)=exp(-3l)     1.818587476 2.187490133 1.944526701 1.67290546
## f(l)= l. 1(l<2)   0.346146508 1.840362680 0.537079791 1.93252004
##                           X5          X6          X7          X8
## Hamming1          0.01076605 0.007453416 0.005797101 0.004140787
## Jaccard           0.41269841 0.305084746 0.245614035 0.181818182
## Spanning Trees    0.02689416 0.007115206 0.003566645 0.010698745
## Hamming           0.03703704 0.025641026 0.019943020 0.084045584
## IM                0.01904677 0.004360756 0.008558174 0.238488731
## HIM               0.02944929 0.018391280 0.015345462 0.178802314
## alpha=0.5,order=5 0.25579558 0.184493603 0.144794887 0.104521541
## alpha=0.5,order=3 0.14233507 0.101166410 0.078960681 0.056821828
## alpha=0.9,order=3 0.09738051 0.068250435 0.052806911 0.037774902
## ST norm           0.01344627 0.003557588 0.001783321 0.005349321
## f(l)=exp(-0.1l)   0.06338556 0.073117935 0.077991566 0.073502055
## f(l)=exp(-0.4l)   0.25354225 0.292471741 0.311966263 0.294008222
## f(l)=exp(-0.9l)   0.57047005 0.658061418 0.701924091 0.661518499
## f(l)=exp(-1.2l)   0.76062674 0.877415224 0.935898788 0.882024665
## f(l)=exp(-3l)     1.90156684 2.193538059 2.339746970 2.205061662
## f(l)= l. 1(l<2)   1.81550160 0.369804772 1.963201411 1.927715992
##                            X9          X10         X11         X12
## Hamming1          0.004554865 0.0033126294 0.002070393 0.007867495
## Jaccard           0.196428571 0.1481481481 0.096153846 0.322033898
## Spanning Trees    0.028719225 0.0012413115 0.019962485 0.009985042
## Hamming           0.031339031 0.0227920228 0.075498575 0.095441595
## IM                0.012888111 0.0069851440 0.226331755 0.227012723
## HIM               0.023960783 0.0168562828 0.168709956 0.174131954
## alpha=0.5,order=5 0.114096660 0.0909259095 0.050099041 0.179873524
## alpha=0.5,order=3 0.062222756 0.0481033159 0.027580114 0.101363150
## alpha=0.9,order=3 0.041722501 0.0312456403 0.018690503 0.070136678
## ST norm           0.014358625 0.0006206557 0.009980911 0.004992479
## f(l)=exp(-0.1l)   0.068025646 0.0539993443 0.048214344 0.073860817
## f(l)=exp(-0.4l)   0.272102583 0.2159973773 0.192857378 0.295443267
## f(l)=exp(-0.9l)   0.612230811 0.4859940989 0.433929100 0.664747351
## f(l)=exp(-1.2l)   0.816307748 0.6479921318 0.578572133 0.886329801
## f(l)=exp(-3l)     2.040769370 1.6199803295 1.446430333 2.215824502
## f(l)= l. 1(l<2)   1.957371381 0.4112206645 0.306073257 0.472603876
##                          X13         X14         X15         X16
## Hamming1          0.00952381 0.008281573 0.006625259 0.006625259
## Jaccard           0.37704918 0.333333333 0.275862069 0.275862069
## Spanning Trees    0.04529120 0.083061049 0.031742648 0.010021195
## Hamming           0.10113960 0.028490028 0.022792023 0.022792023
## IM                0.22280781 0.032751000 0.010921482 0.014175260
## HIM               0.17302101 0.030694541 0.017871137 0.018979124
## alpha=0.5,order=5 0.23192725 0.229948629 0.165387706 0.193765492
## alpha=0.5,order=3 0.12851578 0.121931398 0.090447040 0.100534568
## alpha=0.9,order=3 0.08607953 0.077442537 0.060585835 0.062819025
## ST norm           0.02264173 0.041506664 0.015869992 0.005010555
## f(l)=exp(-0.1l)   0.08472580 0.089340075 0.066630875 0.085084910
## f(l)=exp(-0.4l)   0.33890320 0.357360299 0.266523501 0.340339639
## f(l)=exp(-0.9l)   0.76253219 0.804060673 0.599677877 0.765764187
## f(l)=exp(-1.2l)   1.01670959 1.072080898 0.799570503 1.021018916
## f(l)=exp(-3l)     2.54177397 2.680202244 1.998926257 2.552547290
## f(l)= l. 1(l<2)   0.52746471 0.560016844 0.546590872 0.513032855
##                           X17         X18          X19         X20
## Hamming1          0.005797101 0.009109731 1.076605e-02 0.007453416
## Jaccard           0.245614035 0.360655738 4.126984e-01 0.305084746
## Spanning Trees    0.014793736 0.029787947 1.652426e-04 0.044926015
## Hamming           0.019943020 0.031339031 3.703704e-02 0.025641026
## IM                0.011107159 0.012842786 9.113745e-03 0.023653720
## HIM               0.016141453 0.023948612 2.697038e-02 0.024667394
## alpha=0.5,order=5 0.163236446 0.225769053 2.668600e-01 0.201712203
## alpha=0.5,order=3 0.085644206 0.123611569 1.462074e-01 0.107734991
## alpha=0.9,order=3 0.054371539 0.082976016 9.817701e-02 0.069237575
## ST norm           0.007396733 0.014892872 8.262132e-05 0.022459230
## f(l)=exp(-0.1l)   0.064893707 0.099174568 7.330192e-02 0.077770238
## f(l)=exp(-0.4l)   0.259574827 0.396698271 2.932077e-01 0.311080952
## f(l)=exp(-0.9l)   0.584043362 0.892571111 6.597173e-01 0.699932143
## f(l)=exp(-1.2l)   0.778724482 1.190094814 8.796231e-01 0.933242857
## f(l)=exp(-3l)     1.946811205 2.975237036 2.199058e+00 2.333107143
## f(l)= l. 1(l<2)   0.351326134 0.703455892 2.080747e+00 2.066507948

In the SBM case:

change_pointSBM=test_change_point_realistic(N=70,m=c(10,20),p_mod=c(0.6,0.2),p_disp=c(0.1,0.2),p_creation=c(0.0,0.0),opts=4, T=21,verbose=TRUE,m_disp=c(0,0,0),m_creation=c(2,5,0),go_plot=TRUE,initial_message=TRUE,very_verbose=FALSE,save_graph_seq=FALSE,name_file_ext="",block.sizes=c(24,23,23))
## [1] "Investigating the ability of the distance to detect dynamic regime changes"
## [1] "A graph with N= 70 nodes is considered as per creation model  4"
## [1] "At time t=10, the number of randomly reassigned edges changes from 10  to  20 with new change proba=  NA  vs  0.5 and deletion 0.2"
## [1] "Type of graph generated:  SBM"
## [1] 70
## [1] "stochastic block model: block size c" 
## [2] "stochastic block model: block size 24"
## [3] "stochastic block model: block size 23"
## [4] "stochastic block model: block size 23"

## [1] "time:  1"
## [1] "time:  2"
## [1] "time:  3"
## [1] "time:  4"
## [1] "time:  5"
## [1] "time:  6"
## [1] "time:  7"
## [1] "time:  8"
## [1] "time:  9"
## [1] "time:  10"
## [1] "time:  11"
## [1] "time:  12"
## [1] "time:  13"
## [1] "time:  14"
## [1] "changed back"
## [1] "time:  15"
## [1] "changed back"
## [1] "time:  16"
## [1] "changed back"
## [1] "time:  17"
## [1] "changed back"
## [1] "time:  18"
## [1] "changed back"
## [1] "time:  19"
## [1] "changed back"
## [1] "time:  20"
## [1] "changed back"

print(change_pointSBM$dist)
##                            X1          X2           X3          X4
## Hamming1          0.004968944 0.008281573 0.0049689441 0.008281573
## Jaccard           0.033994334 0.056022409 0.0339943343 0.056022409
## Spanning Trees    0.004025287 0.003056036 0.0004918973 0.005230897
## Hamming           0.004968944 0.008281573 0.0049689441 0.008281573
## IM                0.002989547 0.003477245 0.0019996242 0.006441342
## HIM               0.004100475 0.006351208 0.0037874069 0.007418738
## alpha=0.5,order=5 0.018513143 0.029319819 0.0163379992 0.033063649
## alpha=0.5,order=3 0.008593923 0.013980575 0.0081052566 0.014837397
## alpha=0.9,order=3 0.005938980 0.009872194 0.0058815605 0.009979543
## ST norm           0.002012641 0.001528017 0.0002459487 0.002615442
## f(l)=exp(-0.1l)   0.051164989 0.050581727 0.0448765231 0.068077740
## f(l)=exp(-0.4l)   0.204659957 0.202326909 0.1795060925 0.272310958
## f(l)=exp(-0.9l)   0.460484904 0.455235544 0.4038887082 0.612699656
## f(l)=exp(-1.2l)   0.613979872 0.606980726 0.5385182776 0.816932875
## f(l)=exp(-3l)     1.534949679 1.517451815 1.3462956939 2.042332187
## f(l)= l. 1(l<2)   0.286781439 0.267652952 2.0141527642 1.896723283
##                            X5          X6          X7          X8
## Hamming1          0.012422360 0.009109731 0.007453416 0.007453416
## Jaccard           0.082872928 0.061452514 0.050561798 0.050561798
## Spanning Trees    0.001233198 0.002348791 0.002182196 0.002017211
## Hamming           0.012422360 0.009109731 0.007453416 0.007453416
## IM                0.003970140 0.009780879 0.009361521 0.005657737
## HIM               0.009221633 0.009451264 0.008461427 0.006616774
## alpha=0.5,order=5 0.045000362 0.035001494 0.025446812 0.027986183
## alpha=0.5,order=3 0.021191803 0.015997573 0.012378531 0.012955500
## alpha=0.9,order=3 0.014850666 0.010926874 0.008850283 0.008952873
## ST norm           0.000616599 0.001174395 0.001091098 0.001008605
## f(l)=exp(-0.1l)   0.069599831 0.059548374 0.053312390 0.060236507
## f(l)=exp(-0.4l)   0.278399323 0.238193496 0.213249559 0.240946029
## f(l)=exp(-0.9l)   0.626398477 0.535935367 0.479811508 0.542128566
## f(l)=exp(-1.2l)   0.835197970 0.714580489 0.639748677 0.722838088
## f(l)=exp(-3l)     2.087994924 1.786451223 1.599371692 1.807095220
## f(l)= l. 1(l<2)   2.012733610 2.789726062 1.893488710 1.894066821
##                             X9          X10          X11         X12
## Hamming1          0.0057971014 0.0049689441 0.0066252588 0.006625259
## Jaccard           0.0395480226 0.0339943343 0.0450704225 0.045070423
## Spanning Trees    0.0008942951 0.0001582064 0.0013710567 0.003035661
## Hamming           0.0057971014 0.0049689441 0.0066252588 0.006625259
## IM                0.0033646406 0.0023679307 0.0025168184 0.005737272
## HIM               0.0047395776 0.0038921396 0.0050114084 0.006197191
## alpha=0.5,order=5 0.0200119831 0.0170415307 0.0227768232 0.022916265
## alpha=0.5,order=3 0.0096681908 0.0082666360 0.0110322844 0.011073544
## alpha=0.9,order=3 0.0068927808 0.0059040558 0.0078609354 0.007861061
## ST norm           0.0004471475 0.0000791032 0.0006855282 0.001517829
## f(l)=exp(-0.1l)   0.0443575252 0.0512426308 0.0526608045 0.052499480
## f(l)=exp(-0.4l)   0.1774301008 0.2049705234 0.2106432179 0.209997919
## f(l)=exp(-0.9l)   0.3992177268 0.4611836776 0.4739472402 0.472495318
## f(l)=exp(-1.2l)   0.5322903024 0.6149115701 0.6319296536 0.629993758
## f(l)=exp(-3l)     1.3307257560 1.5372789254 1.5798241339 1.574984395
## f(l)= l. 1(l<2)   1.9326566416 0.3418838897 0.3225504692 2.005511216
##                            X13          X14         X15         X16
## Hamming1          0.0041407867 0.0049689441 0.010766046 0.012422360
## Jaccard           0.0284090909 0.0339943343 0.072222222 0.082872928
## Spanning Trees    0.0009108246 0.0003169750 0.003059647 0.002116107
## Hamming           0.0041407867 0.0049689441 0.010766046 0.012422360
## IM                0.0018328213 0.0037817913 0.004655034 0.008125050
## HIM               0.0032019798 0.0044154474 0.008293886 0.010495987
## alpha=0.5,order=5 0.0150126866 0.0186803318 0.040684334 0.046353353
## alpha=0.5,order=3 0.0070777924 0.0086496021 0.018779811 0.021521197
## alpha=0.9,order=3 0.0049398140 0.0059837633 0.012911484 0.014866044
## ST norm           0.0004554123 0.0001584875 0.001529822 0.001058053
## f(l)=exp(-0.1l)   0.0443123707 0.0513133229 0.070517624 0.079344060
## f(l)=exp(-0.4l)   0.1772494830 0.2052532917 0.282070495 0.317376238
## f(l)=exp(-0.9l)   0.3988113367 0.4618199063 0.634658613 0.714096536
## f(l)=exp(-1.2l)   0.5317484489 0.6157598750 0.846211484 0.952128714
## f(l)=exp(-3l)     1.3293711222 1.5393996875 2.115528710 2.380321785
## f(l)= l. 1(l<2)   0.2617769467 2.0022325272 0.417202744 2.042368630
##                            X17          X18          X19         X20
## Hamming1          0.0099378882 0.0115942029 1.159420e-02 0.010766046
## Jaccard           0.0668523677 0.0775623269 7.756233e-02 0.072222222
## Spanning Trees    0.0007382557 0.0009260007 4.088094e-05 0.002015864
## Hamming           0.0099378882 0.0115942029 1.159420e-02 0.010766046
## IM                0.0035488950 0.0092941838 6.726610e-03 0.008352004
## HIM               0.0074617785 0.0105073163 9.478207e-03 0.009634929
## alpha=0.5,order=5 0.0360942102 0.0429219855 4.340994e-02 0.039343345
## alpha=0.5,order=3 0.0170153320 0.0200090502 2.011883e-02 0.018480517
## alpha=0.9,order=3 0.0119236259 0.0139123426 1.390756e-02 0.012880799
## ST norm           0.0003691279 0.0004630003 2.044047e-05 0.001007932
## f(l)=exp(-0.1l)   0.0630793948 0.0649429004 6.837157e-02 0.061264679
## f(l)=exp(-0.4l)   0.2523175791 0.2597716015 2.734863e-01 0.245058716
## f(l)=exp(-0.9l)   0.5677145530 0.5844861034 6.153441e-01 0.551382111
## f(l)=exp(-1.2l)   0.7569527374 0.7793148046 8.204588e-01 0.735176148
## f(l)=exp(-3l)     1.8923818434 1.9482870115 2.051147e+00 1.837940371
## f(l)= l. 1(l<2)   0.3494728932 1.9886788049 2.012258e+00 2.812357379

IV. Compare ability to recognize classes of graphs

Here we brefly compare the different distances’ ability to distinguish graphs that exhibit different topological properties. We generate 6 E-R graphs on 60 nodes, 6 Power law graphs, 6 island graphs, as well as 6 SBM networks. We compute the pairwise distances between the different graphs. If all goes well, the distance should cluster the different topologies together, and the heatmap should exhibit a block diagonal structure.

N=60
K=6
A<-vector("list",4*K)
args<-list(p=0.1,power=1.4,islands.n=3,islands.size=20,islands.pin=0.3,n.inter=3,K=6,block.sizes=c(20,20,20),pm=cbind( c(.4,0.1, .001), c(.1,0.2, .01),c(.001,0.01, .5)))
verbose=FALSE

for (i in 1:K){
  A[[i]]<-generate_random_adjacency(N,0.3, TRUE)
  A[[i+K]]<-generate_realistic_adjacency(N,opts=1, verbose=verbose)
  A[[i+K]]=as(get.adjacency(A[[i+K]]),"matrix")
  A[[i+2*K]]<-generate_realistic_adjacency(N,opts=2, verbose=verbose,islands.n=3,islands.size=20)
  A[[i+2*K]]=as(get.adjacency(A[[i+2*K]]),"matrix")
  A[[i+3*K]]<-generate_realistic_adjacency(N,opts=4, verbose=verbose,block.sizes=c(20,20,20))
  A[[i+3*K]]=as(get.adjacency(A[[i+3*K]]),"matrix")
}

print("generated")
## [1] "generated"
distances<-vector("list",8)
names=vector("list",8)
name_distance=c('Jaccard','Spanning Trees','Hamming','IM','HIM','Polynomial (ord=3,a=0.5)','Eigen f(lambda)=exp(-1.2*lambda)','Eigen f(lambda)=lambda. 1{lambda<2}')
for (k in 1:8){
  distances[[k]]=matrix(0,4*K,4*K)
  names[[k]]=paste("Heatmap of the pairwise distances between graphs \n", name_distance[k])
}

for (j in 2:(4*K)){
  for (i in 1:(j-1)){
    
    sp_Anew=get_number_spanning_trees(A[[i]])
    sp_A=get_number_spanning_trees(A[[j]])
    distances[[2]][i,j]=abs(log(max(sp_A,1))-log(max(1,sp_Anew)))
    distances[[1]][i,j]<-jaccard_based_distance(A[[i]], A[[j]])
    temp<-netdist(A[[i]], A[[j]],d = "HIM")
    distances[[3]][i,j]=temp[1]
    distances[[4]][i,j]=temp[2]
    distances[[5]][i,j]=temp[3]
    distances[[6]][i,j]<-poly_distance(A[[i]], A[[j]],order_max=3,alpha=0.5)
    distances[[7]][i,j]<-eigen_distance(A[[i]], A[[j]],function(x){return(exp(-1.2*x))},p=2)
    distances[[8]][i,j]<-eigen_distance(A[[i]], A[[j]],function(x){ifelse(x<2,x,0)})
  }
}


for (k in 1:8){
  distances[[k]]=distances[[k]]+t(distances[[k]])
  heatmap.2(distances[[k]],dendrogram='none', Rowv=FALSE, Colv=FALSE,trace='none',main=names[[k]])
}